/*
 * @Author: your name
 * @Date: 2021-09-03 09:51:03
 * @LastEditTime: 2021-09-03 10:39:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day10\2-构造函数模式.js
 */

//把构造函数里面的sayName函数进行抽取,使得sayName函数成为全局变量
function sayName() {
    console.log(this.name);
}

function Person(name, age, gender) {
    this.name = name,
        this.age = age,
        this.gender = gender,

        // this.sayName = function() {
        //     console.log(this.name);
        // }
        this.sayName = sayName
}
var p1 = new Person('terry', 12, "男");
p1.sayName(); //terry
console.log(p1); //terry
/*Person {
name: 'terry',
age: 12,
gender: '男',
 sayName: [Function (anonymous)]
 }*/
console.log(typeof p1); //object